package com.hualan.sfzy.controller.mind;
import com.hualan.sfzy.entity.mind.MindTest;
import com.hualan.sfzy.service.mind.MindTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("mindTest")
public class MindTestController {
    @Autowired
    private MindTestService mindTestService;

    @PostMapping
    public int insert(@RequestBody MindTest mindTest) {
        return mindTestService.add(mindTest);
    }

    @PutMapping
    public int update(@RequestBody MindTest mindTest) {
        return mindTestService.edit(mindTest);
    }

    @DeleteMapping("/{id}")
    public int delete(@RequestParam Integer id) {
        return mindTestService.remove(id);
    }

    @DeleteMapping ()
    public int deleteBatch(@RequestParam Integer[] ids) {
        return mindTestService.removeBatch(ids);
    }

    @GetMapping
    public List select() {
        List<MindTest> list =  mindTestService.find();
        return list;
    }

    @GetMapping("/{id}")
    public MindTest selectById(@PathVariable Integer id) {
        return mindTestService.findById(id);
    }

    @GetMapping("/page")
    public Map<String, Object> findByPage(@RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "10") Integer pageSize,
                                           MindTest mindTest) {
        return mindTestService.findByPage(pageNum, pageSize, mindTest);
    }
}